package com.iot.apicontrol.controller;


import com.dc3.common.bean.R;
import com.iot.apicontrol.dto.Dc3ApiControlDto;
import com.iot.apicontrol.service.Dc3ApiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author 咕唧
 * @Date 2022/7/22 11:22
 * @Version 1.0
 */
@RequestMapping("/api")
@RestController
public class Dc3ApiController {
    private Dc3ApiService dc3ApiService;

    @Autowired
    public void setDc3ApiService(Dc3ApiService dc3ApiService) {
        this.dc3ApiService = dc3ApiService;
    }

    @PostMapping("/list/simple")
    public R findAllApi2Dto() {
        return R.ok(dc3ApiService.findAllApi2Dto());
    }

    @PostMapping("/add")
    public R addApi(@RequestBody Dc3ApiControlDto dc3ApiControlDto) {
        dc3ApiService.addApi(dc3ApiControlDto);
        return R.ok();
    }

    @PostMapping("/delete")
    public R deleteApi(String id) {
        return R.ok(dc3ApiService.deleteApi(id));
    }

}
